package com.example.demo.controller;

import com.example.demo.pojo.Result;
import com.example.demo.pojo.vo.QuestionCategoryVO;
import com.example.demo.pojo.vo.QuestionVO;
import com.example.demo.service.imply.ICategoryServiceImply;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/category")
@Slf4j
@Api(tags = "题型相关接口")
@RequiredArgsConstructor
@CrossOrigin(origins = {"http://localhost:8080"}, allowCredentials = "true")
public class CategoryController {
    private final ICategoryServiceImply categoryServiceImply;
    @ApiOperation("初始化")
    @PostMapping("/init")
    public Result initBank(){
        List<QuestionCategoryVO>questionCategoryVoList=categoryServiceImply.initCategoryList();
        if(questionCategoryVoList.isEmpty()){
            return Result.error("题库缺少");
        }
        return Result.success(questionCategoryVoList);
    }
}
